<template>
	<view>
		<view class="item u-flex u-flex-1" v-for="(item,index) in list.filter((it,ii)=>ii===0)" :key="index">
			<view class="avatar" @click="showIndex(item)">
				<image :src="imgUrl(item.avatar)" />
			</view>
			<view class="info-wrap u-flex-1" @click="showIndex(item)">
				<view class="top-title u-flex">
					<view class="title u-flex-1 u-flex">
						<view class="name">{{item.nickname}}</view>
						<view class="type">房联</view>
						<view class="score">{{Number(item.score)}}</view>
					</view>
				</view>
				<view class="label u-flex">
					<view v-for="(i,iindex) in item.admin_tag_ids" :key="iindex">{{i}}</view>
				</view>
				
			</view>
			<view class="handle u-flex">
				<text class="iconfont icon-meirixiaoxituisong"
					@click="jump(`/pages/chat/detail?id=${item.id}&name=${item.nickname}&avatar=${item.avatar}`)"></text>
				<text @click="callPhone(item.phone)" class="iconfont icon-telephone"></text>
				<text @click="ding(0,item)">定</text>
				<text @click="ding(1,item)">意</text>
			</view>
		</view>

		<!-- 定金 -->
		<u-popup v-model="dingShow" mode="center" border-radius="30">
			<view class="ding-price">
				<view class="title-top u-flex">
					<view class="title">{{types ? '意向金' : '定金'}}</view>
					<u-icon name="close-circle" color="#666" size="40" @click="dingShow = !1"></u-icon>
				</view>
				<view class="content u-flex">
					<view class="icon-img">
						<image src="/static/images/Ding-tips.png" mode="widthFix"></image>
					</view>
					<view>{{types ? '精品好房，有意向可支付意向金！' : '我已全面了解房源信息，自愿线上定房'}}</view>
				</view>
				<view class="enter u-flex">
					<text @click="goPay">进入</text>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		name: "detail-steward-list",
		data() {
			return {
				dingShow: !1,
				types: 0,
				items: ''
			};
		},
		props: ['list', 'type', 'did', 'info'], //type 房型，did房子id
		methods: {
			callPhone(phone) {
				uni.makePhoneCall({
					phoneNumber: phone
				})
			},
			showIndex(item) {
				// 此item为管家
				uni.showActionSheet({
					itemList: ['预约带看', '在线咨询', '交易管家'],
					success: (res) => {
						let t_item = {
							...item,
							build_type: this.type,
							did: this.did,
							house_deposit: this.info.house_deposit
						}
						let data = encodeURIComponent(JSON.stringify(t_item))
						res.tapIndex === 0 && this.$app.jump('/pages/house/more/daikan-notice?data=' + data)
						res.tapIndex === 1 && this.$app.jump('/pages/chat/detail?id=' + item.id)
						res.tapIndex === 2 && this.$app.jump('/pages/house/more/steward?data=' + data)
					}
				})
			},
			ding(types, item) {
				this.types = types
				this.items = item
				this.dingShow = !0
			},
			goPay() {
				this.$app.jump(
					`/pages/house/pay/pay-contract?id=${this.did}&type=${this.type}&types=${this.types}&ids=${this.items.id}&house_deposit=${this.types?this.info.intention_money:this.info.earnest_money}`
					)
				this.dingShow = !1
			}
		}
	}
</script>

<style lang="scss" scoped>
	.item {
		display: flex;
	}

	.avatar image {
		width: 110rpx;
		flex: 0 0 110rpx;
		height: 110rpx;
		margin-right: 20rpx;
		border-radius: 50%;
	}

	.info-wrap {
		width: 0;
		padding: 20rpx 0;

		.top-title {
			.title {
				overflow: hidden;

				view {
					margin: 0 6rpx;
				}

				.name {
					font-size: 30rpx;
					font-weight: bold;
					margin-left: 0;
				}

				.type {
					background-color: #4edcc5;
					color: #fff;
					font-size: 24rpx;
					padding: 2rpx 10rpx;
					border-radius: 6rpx;
					white-space: nowrap;
				}

				.score {
					color: #f00;
					font-size: 28rpx;
					margin-right: 0;
				}
			}
		}

		.label {
			padding: 10rpx 0;
			flex-wrap: wrap;

			view {
				border: 1rpx solid #ccc;
				font-size: 20rpx;
				border-radius: 8rpx;
				padding: 4rpx 10rpx;
				margin-right: 10rpx;
				margin-top: 4rpx;

				&:last-child {
					margin-right: 0;
				}
			}
		}
	}

	.handle {
		text {
			background-color: #ffd7d7;
			color: #ff1e1e;
			width: 60rpx;
			height: 60rpx;
			text-align: center;
			line-height: 60rpx;
			border-radius: 50%;
			margin-right: 10rpx;

			&:last-child {
				margin-right: 0;
			}

			font-weight: bold;
		}
	}

	// 定金模态框
	.ding-price {
		width: 700rpx;

		.title-top {
			justify-content: space-between;
			border-bottom: 1rpx solid #ddd;
			height: 90rpx;
			padding: 0 30rpx;

			.title {
				font-size: 32rpx;
				font-weight: bold;
			}
		}

		.content {
			flex-direction: column;

			.icon-img {
				padding: 33rpx 0;
			}

			image {
				width: 230rpx;
			}
		}

		.enter {
			justify-content: flex-end;
			height: 100rpx;

			text {
				background-color: $tc;
				color: #fff;
				font-size: 26rpx;
				padding: 8rpx 40rpx;
				border-radius: 10rpx;
				margin-right: 30rpx;
			}
		}
	}
</style>
